<?php
	session_start();
	/**
	* @package ParkFind
	* @desc Profile page where profile is viewed.
	*/

	if(!isset($_SESSION['user_id']))
	{
		header('Location: index.php');
		exit();
	}
	
	
	/**
	* @desc This include file will load the directory settings for the Smarty Templates
	*/
	require 'includes/smarty.inc';
	$smarty->assign('user_id', $_SESSION["user_id"]);	
	$smarty->assign('title', "My Profile");	
	$smarty->assign('last', $_SESSION["lastviewed"]);
	$smarty->assign('firstname', $_SESSION["firstname"]);
	$smarty->assign('role', $_SESSION["role"]);
	$smarty->assign('top5', $_SESSION["top5"]);	
	$smarty->display('header.tpl');
	
	
	$id = $_SESSION['user_id'];
				
	/**
	* @desc This include file connects to the database.
	*/
	require 'includes/connect.inc';
	
	//get user info
	$query = "SELECT firstname, lastname, email, role FROM users WHERE user_id = $id";
	
	// Prepare smart template
	/*
	*desc Location to profile template
	*/ 
	define("USER_HOME_DIR", "/home/stud/s3299807");
	/**
	* @desc This include file will load the directory settings for the Smarty Templates
	*/


	$result = mysql_query($query, $connection);
	$row = mysql_fetch_array($result);
	
	$fname = $row['firstname'];
	$lname = $row['lastname'];
	$email = $row['email'];
	$role = $row['role'];
	
	mysql_close($connection);
	
	$smarty->assign('id', $id);
	$smarty->assign('fname', $fname);
	$smarty->assign('lname', $lname);
	$smarty->assign('email', $email);
	$smarty->assign('role', $role);
	
	$smarty->display('profile.tpl');
	
	$smarty->display('footer.tpl');
	
?>